import React, { Component } from 'react'

export class SetStatejs extends Component {
  state = {
    count: 1
  }
  handleCount = () => {
    this.setState({
      count: 2
    })
    this.setState(state => {
      console.log(state.count);
      return {
        count: state.count + 1
      }
    })
  }

  render() {
    return (
      <div>
        <h1>{this.state.count}</h1>
        <button onClick={this.handleCount}>+1</button>
      </div>
    )
  }
}